package bean;

import org.apache.hadoop.io.Writable;

import javax.xml.crypto.Data;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * This class used to save metric data
 *@author :chensi
 */
public class DataPoint implements Writable{
    private String dn;
    private long ts;
    private double value;
    @Override
    public String toString() {
        return "DataPoint{" +
                "dn='" + dn + '\'' +
                ", ts=" + ts +
                ", value=" + value +
                '}';
    }

    public String getDn() {
        return dn;
    }

    public void setDn(String dn) {
        this.dn = dn;
    }

    public DataPoint(){

    }

    public DataPoint(String dn, long ts, double value) {
        this.dn = dn;
        this.ts = ts;
        this.value = value;
    }

    public long getTs() {
        return ts;
    }

    public void setTs(long ts) {
        this.ts = ts;
    }

    public double getValue() {
        return value;
    }

    public void setValue(double value) {
        this.value = value;
    }

    @Override
    public void write(DataOutput out) throws IOException {
        out.writeLong(ts);
        out.writeUTF(dn);
        out.writeDouble(value);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        this.ts = in.readLong();
        this.dn = in.readUTF();
        this.value = in.readDouble();
    }

}
